﻿{% extends "base.html" %}

{% block title %}
{% if user_name %}
{{ user_name }} 的报表
{% else %}
部门的报表
{% endif %}
{% endblock %}
{% block user %}
{% if user_name %}
{{ user_name }} 的报表
{% else %}
部门的报表
{% endif %}
{% endblock %}

{% block styles %}
{{super()}}
<link href="{{ url_for("static", filename="css/dashboard.css") }}" rel="stylesheet">
<style>
    .col-center-block {
        float: none;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
</style>
{% endblock %}

{% block scripts %}
{{super()}}

<script>
    // datatable
    $(function () {
        // $('#weeklytimesheet').DataTable(
        $('.dt').DataTable(
            {

                "search": {
                    "regex": true
                },
                dom: '<"top"flipB<"clear">>rt<"bottom"ipB<"clear">>',
                buttons: [
                    'copy', 'csv', 'excel'
                ],

                //"order": [[0, "asc"]],
                "order": [],

                "autoWidth": false

            });
    });

    // jmo all
    {% if jmoall %}
    $(function () {
        var graphs = {{ jmoall | safe
    }};
    Plotly.plot('jmoAll', graphs, {});
});
    {% endif %}

    // jmo month project
    {% if jmomonth %}
    $(function () {
        var graphs = {{ jmomonth | safe
    }};
    Plotly.plot('jmomonth', [graphs], {});
});
    {% endif %}

    // jmo month category
    {% if jmomonthcategory %}
    $(function () {
        var graphs = {{ jmomonthcategory | safe
    }};
    Plotly.plot('jmomonthcategory', [graphs], {});
});
    {% endif %}

    // jmo month subcategory
    {% if jmomonthsubcategory %}
    $(function () {
        var graphs = {{ jmomonthsubcategory | safe
    }};
    Plotly.plot('jmomonthsubcategory', [graphs], {});
});
    {% endif %}

    // plot monthly report
    {% if timesheet_by_month %}
    $(function () {
        var graphs = {{ timesheet_by_month[1] | safe
    }};
    console.log(graphs);
    Plotly.plot('monthlytimesheet', [graphs], {});
});
    {% endif %}



</script>
{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="main">
        <div class="row">
            {% include 'flash_message.html' %}
            <!-- 技术部工时分布   -->
            <div>
                {% if jmoall %}
                <h3 class="page-header">
                    重工模块技术部 工时分布图(按天)
                </h3>
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="chart" id="jmoAll">
                    </div>
                </div>
                {% endif %}

                {% if jmomonth %}
                <h3 class="page-header">
                    重工模块技术部 {{ month }} 月份工时分布图 ({{ jmomanhour_month }}小时)
                </h3>
                <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
                    <div class="chart" id="jmomonth">
                    </div>
                </div>
                <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
                    <div class="chart" id="jmomonthcategory">
                    </div>
                </div>
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="chart" id="jmomonthsubcategory">
                    </div>
                </div>
                {% endif %}

            </div>
            <!-- 个人按月统计工时    -->
            <div>
                {% if timesheet_by_month %}
                <h3 class="page-header">
                    {{ user_name }}的 {{ month }} 月份工时分布
                    (项目:{{ usermanhour_month }}h;
                    {% for r in uservacation %}
                    {{ r[0] }}:{{ r[1] }}h;
                    {% endfor %}
                    )
                </h3>
                <h5>

                </h5>
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="chart" id="monthlytimesheet">
                    </div>
                </div>
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <table class="dt row-border hover compact" style="width:100%">
                        <thead>
                            <tr>
                                <th>工作令号</th>
                                <th>项目名称</th>
                                <th>工时</th>
                                <th>任务</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for row in timesheet_by_month[0] %}
                            <tr>
                                {% for td in row %}
                                <td>{{ td }}</td>
                                {% endfor %}
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% endif %}
            </div>
            <!-- 个人按周统计工时   -->
            <div>
                {% if timesheet_by_week %}
                <h3 class="page-header col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    {{ user_name }} 的工时统计(按周)
                </h3>
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <table id="weeklytimesheet" class="dt row-border hover compact" style="width:100%">
                        <thead>
                            <tr>
                                {% for th in timesheet_by_week[0] %}
                                <th>{{ th }}</th>
                                {% endfor %}
                            </tr>
                        </thead>
                        <tbody>
                            {% for row in timesheet_by_week[1:] %}
                            <tr>
                                {% for td in row %}
                                <td>{{ td }}</td>
                                {% endfor %}
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% endif %}
            </div>
            <!-- iMES按月统计工时   -->
            <div>
                {% if imesdata %}
                <h3 class="page-header col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    iMES管理成本统计表({{ month }}月份)
                </h3>
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <table id="imesdata" class="dt row-border hover compact" style="width:100%">
                        <thead>
                            <tr>
                                {% for th in imesdata[0] %}
                                <th>{{ th }}</th>
                                {% endfor %}
                            </tr>
                        </thead>
                        <tbody>
                            {% for row in imesdata[1:] %}
                            <tr>
                                {% for td in row %}
                                <td>{{ td | replace('JMH重工模块事业本部技术部','') }}</td>
                                {% endfor %}
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}